logic help needed. Thank you

Hello,

Is there a better way of creating the userlist within my script I would like it to execute logic quicker, currently I have 250+ users and it take abot 10 sec to create the list three twices as long if the user is wireless. Also is there a better way writing the logic for my ReadOnly function.
 

//<
//Title: grantRemoveAccess.dxl
//Author: Scott Boisvert
//Date: 20 May 2008
//Brief:
/***********************************************************
* This script allows the user to set or remove access to
* multiple items in the DOORS database for multiple users
* and/or groups.
***********************************************************/
//Updated: 
/***********************************************************
* 05/28/08
* Corrected issue of modules not being removed correctly
* from the item list. Also added functionality so deleted
* items are not populated in the item list.
***********************************************************/
 
pragma runLim, 0
 
DB db
 
DBE userListView
DBE optionIndividualUser
DBE optionAppendUsers
DBE accessListView
DBE moduleList
 
DBE    treeFrame
DBE     listFrame
DBE     itemTree
DBE     itemList
 
Skip selectedItems = getSelectedItems ()
Skip items = create ()
Skip DBuserList = createString ()
 
// Engineering
put(DBuserList, "tester1","Engineering Lead")
// IV&V
put(DBuserList, "tester2","IV&V Lead")
// CTF
put(DBuserList, "tester3","CTF")
 
int numItems
 
 
User u = null
string Uname = null
// Get Current User.  
u = find(); Uname = u.name;
 
/**********************************
        itemsSelected
***********************************/
bool itemsSelected()
{
        bool ret = true
        int listnum = noElems (moduleList)
        
        if (listnum < 1) {ret = false}
        
        return ret
}//End itemsSelected.
 
/**********************************
        userSelected
***********************************/
bool userSelected()
{
        bool ret = false
        int i
                
        for (i = noElems (userListView); i >= 0; i--)
        {
                if (selected (userListView, i))
                {
                        ret = true
                        break
                }
        }
        
        return ret
}//End userSelected.
 
/**********************************
        validation
***********************************/
bool validation()
{
        bool ret = true
        
        Group LG = find("Engineering Lead")
        Group IG = find("IV&V Lead")
        Group CTF = find("CTF")
        
        if (Uname != "Administrator")
        {    
                if(member(LG, u) && member(IG, u)) 
                {
                        errorBox(Uname " Cannot be apart of both Groups {Engineering/IV&V}!\nPlease see the Administrator")
                        ret = false
                }
                else
                {
                        string userGroup = null
                        if(!find(DBuserList,Uname,userGroup))
                        {
                                errorBox(Uname " is not an authorized user!")
                                ret = false
                        }
                        else if (!member(LG, u) && !member(IG, u)) 
                        { 
                                if(!member(CTF, u))
                                {
                                        errorBox(Uname " is an authorized user but is not apart of the correct Usergroup\nPlease see the Administrator!")
                                        ret = false
                                }
                        }
                }
        }
        
        return ret
}//End validation
 
/**********************************
        optionCallback
***********************************/
void optionCallback (DBE win)
{
        if(get(optionIndividualUser))
        {
                int i
                //Loop through the module list.
                for (i = noElems (accessListView); i >= 0; i--)
                {    
                        //If the item is selected then remove it from list to process.
                        if (getCheck (accessListView, i))
                        {    
                                setCheck(accessListView, i, false)
                        }    
                }
                        
                inactive(accessListView)
                active(userListView)
                active(optionAppendUsers)               
        }
        else
        {
                int i
                                        
                //Loop through the module list.
                for (i = noElems (userListView); i >= 0; i--)
                {    
                        //If the item is selected then remove it from list to process.
                        if (selected (userListView, i))
                        {    
                                set (userListView, i,false)
                        }    
                }
                        
                set(optionAppendUsers,false)
                active(accessListView)
                inactive(userListView)
                inactive(optionAppendUsers)                             
        }
 
}//End optionCallback.
 
/**********************************
        permission (recursive)
***********************************/
Permission permission (AccessRec ar) {
  Permission returned = none
  if read(ar)    then returned = returned | read
  if modify(ar)  then returned = returned | modify
  if create(ar)  then returned = returned | create
  if delete(ar)  then returned = returned | delete
  if control(ar) then returned = returned | control
  return returned
}//End permission.
 
/**********************************
        permission (recursive)
***********************************/
string permission (Permission p){
  string returned = ""
  if (p & read    == read   ) returned = returned "R"
  if (p & modify  == modify ) returned = returned "M"
  if (p & create  == create ) returned = returned "C"
  if (p & delete  == delete ) returned = returned "D"
  if (p & control == control) returned = returned "A"
  if (returned    == ""     ) returned = "none"
  return returned
}//End permission.
 
/**********************************
        ReadOnly
***********************************/
bool ReadOnly(Item I)
{
        bool ret = true
        AccessRec ar
        string userG = null
        int cnt = 0
 
        for ar in all I do 
        {
                userG = username(ar) " " permission(permission(ar))
                if(isDefault(ar))
                {
                        if(permission(permission(ar)) != "R")
                        {
                                ret = false
                        }
                }
                else if(userG != "CTF RMCA")
                {
                        ret = false
                }
                cnt++
        }
        
        if (cnt < 2) {ret = false}
        
        return ret
}//End ReadOnly.
 
/**********************************
        freeResources
***********************************/
void freeResources()
{
        //Free resources...
        delete selectedItems
        delete items
        delete DBuserList
        
        refreshDBExplorer() 
}//End freeResources.
 
/**********************************
        sortListView
***********************************/
int sortListView (string s1, string s2)
{//Call back function to sort listViews.
        if (s1 == s2)
        {
                return 0
        }
        else if (s1 > s2)
        {
                return 1
        }
        else if (s1 < s2)
        {
                return -1
        }
}//End sortListView.
 
/**********************************
        SetModAccess
***********************************/
void SetModAccess(Item m, Permission psn, string NameUser)
{    
        string err = set(m, psn, NameUser) // Set UserGroup/User. 
        if (!null err){errorBox(fullName(m) "\n" err)}
}//End SetModAccess().
 
/**********************************
        resetInhertance (recursive)
***********************************/
void Reset(Object obj)
{  
        bool IsInherited = false
        isAccessInherited(obj, IsInherited)
        if (!IsInherited and !isDeleted(obj) and canModify(obj))
        {
                inherited(obj)
                specific(obj)
        }
        Object oChild
        // ** RECURSION **
        for oChild in obj do
        {
                Reset(oChild)
        }
}//End Reset(Obj)
 
/**********************************
        resetInhertance (recursive)
***********************************/
void Reset(Module mod)
{  
        Object oTop
        // ** RECURSION **
        for oTop in top(mod) do 
        {
                Reset(oTop)
        }
}//End Reset(Mod)
 
/**********************************
        applyUserGroup
***********************************/
void applyUserGroup(DB win)
{
        if (itemsSelected())
        {
                Item I 
                
                if (getCheck (accessListView, 0) || getCheck (accessListView, 1) || getCheck (accessListView, 2))
                {
                        //Loop through the items to apply access.
                        for I in items do
                        {
                                if (type (I) != "Formal") {continue}
                                
                                // set access control to be specific rather than inherited.
                                err = specific(I) 
                                if (!null err){errorBox(fullName(I) "\n" err)}
                                
                                //None is selected.
                                if (getCheck (accessListView, 0))
                                {    
                                        //ClearAccess
                                        AccessRec ar
                                        
                                        // Remove all access {user access}.
                                        for ar in all I do 
                                        {
                                                string userGroup = null
                                                if (find(DBuserList,Uname,userGroup) || Uname == "Administrator")
                                                {
                                                        if (!isDefault( ar ) && username(ar) != userGroup)
                                                        {err = unset(I, username(ar))
                                                        if (!null err){errorBox(err)}} 
                                                }
                                        }
                                                
                                        SetModAccess(I, read, null) // Everyone else (R).
                                }
                                if (getCheck (accessListView, 0) && !getCheck (accessListView, 1) && !getCheck (accessListView, 2))
                                {
                                        // Set UserGroup/User
                                        SetModAccess(I, control, "CTF") // (RMCA).
                                        err = setImplied(I, null) // Turn off Propagate access rights.
                                                //if (!null err){errorBox(err)}
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 1))
                                {
                                        // Set UserGroup/User
                                        SetModAccess(I, control, "Engineering Lead") // (RMCA).
                                        err = setImplied(I, null) // Turn off Propagate access rights.
                                                //if (!null err){errorBox(err)}
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 2))
                                {
                                        // Set UserGroup/User
                                        SetModAccess(I, control, "IV&V Lead") // (RMCA).
                                        err = setImplied(I, null) // Turn off Propagate access rights.
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 3))
                                {
                                        // Set UserGroup/User
                                        SetModAccess(I, read|create|modify, "Application Engineer") // (RC).
                                        err = setImplied(I, delete) // Propagate access rights (MD).
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 4))
                                {
                                        // Set UserGroup/User
                                        SetModAccess(I, read|create|modify, "1E Engineer") // (RC).
                                        err = setImplied(I, delete) // Propagate access rights (MD).
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 5))
                                {
                                        // Set UserGroup/User
                                        SetModAccess(I, read|create|modify, "Hardware Engineer") // (RC).
                                        err = setImplied(I, delete) // Propagate access rights (MD).
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 6))
                                {
                                        SetModAccess(I, read|modify, "IV&V Engineer") // (RM).
                                        err = setImplied(I, null) // Turn off Propagate access rights.
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 7))
                                {
                                        // Set UserGroup/User
                                        SetModAccess(I, read|create|modify, "CNCS Engineer") // (RC).
                                        err = setImplied(I, delete) // Propagate access rights (MD).
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                if (getCheck (accessListView, 8))
                                {
                                        SetModAccess(I, read|modify, "CNCS IV&V Engineer") // (RM).
                                        err = setImplied(I, null) // Turn off Propagate access rights.
                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                }
                                
                                Module m = edit(fullName(I), false, true)
                                
                                if(!null m)
                                {
                                        Reset(m)        
 
                                        // Remove userGroup access.
                                        string userGroup = null
                                        find(DBuserList,Uname,userGroup)
 
                                        if ((userGroup == "Engineering Lead" && !getCheck (accessListView, 1)) || (userGroup == "IV&V Lead" && !getCheck (accessListView, 2)))
                                        {
                                                err = unset(m, userGroup)
                                                        if (!null err){errorBox(err)}
                                        }   
                                        
                                        save(m)
                                        close(m)
                                }else{errorBox("{Null} "fullName(I)"!")}
                        }
                                        
                        infoBox ("Done!")
                        freeResources()
                        destroy(db)
                        
                }else {warningBox("{Null Parameters} Permissions")}
        }else {warningBox "No item(s) selected!"}
}//End applyAccess
 
/**********************************
        applyUser
***********************************/
void applyUser (DB win)
{
        if(itemsSelected())
        {
                if (userSelected())
                {
                        Item I 
                        
                        //Loop through the items to apply access.
                        for I in items do
                        {
                                if (type (I) != "Formal") {continue}
                                        
                                // set access control to be specific rather than inherited.
                                err = specific(I) 
                                if (!null err){errorBox(fullName(I) "\n" err)}
                                
                                if(!get(optionAppendUsers))
                                {                   
                                        //ClearAccess
                                        AccessRec ar
                                                        
                                        // Remove all access {user access}.
                                        for ar in all I do 
                                        {
                                                string userGroup = null
                                                if (find(DBuserList,Uname,userGroup) || Uname == "Administrator")
                                                {
                                                        if (!isDefault( ar ) && username(ar) != userGroup)
                                                        {err = unset(I, username(ar))
                                                        if (!null err){errorBox(err)}} 
                                                }
                                        }
                                        SetModAccess(I, read, null) // Everyone else (R).
                                }
                                else
                                {
                                        //Remove only Usergroups
                                        Group g
                                        bool ugDisabled 
                                        string ugName
                                        
                                        for g in groupList do
                                        {
                                                ugDisabled = g.disabled
                                                
                                                if (!ugDisabled)
                                                {
                                                        ugName = g.name
                                                        
                                                        string userGroup = null
                                                        find(DBuserList,Uname,userGroup)
                                                        
                                                        if(userGroup == ugName) continue
 
                                                        err = unset(I, ugName)
                                                                if (!null err){errorBox(err)}
                                                }   
                                        }
                                        SetModAccess(I, read, null) // Everyone else (R).
                                }
                                
                                int i
                                
                                //Loop through the module list.
                                for (i = noElems (userListView); i >= 0; i--)
                                {   
                                        //If the item is selected then remove it from list to process.
                                        if (selected (userListView, i))
                                        {   
                                                string DBuser = get (userListView, i)
                                                string userGroup = null
                                                        
                                                if (find(DBuserList,Uname,userGroup))
                                                {
                                                        Group EG = find("Engineering Lead")
                                                        Group IL = find("IV&V Lead")
                                                        Group AE = find("Application Engineer")
                                                        Group EE = find("1E Engineer")
                                                        Group IE = find("IV&V Engineer")
                                                        Group CE = find("CNCS Engineer")
                                                        
                                                        if(userGroup == "Engineering Lead")
                                                        {
                                                                u = find(DBuser)
                                                                if ((member(EG, u) || member(AE, u) || member(EE, u) || member(CE, u)) || (!member(IL, u) &&  !member(IE, u)))
                                                                {
                                                                        // Set UserGroup/User
                                                                        SetModAccess(I, read|create|modify, DBuser) // (RC).
                                                                        err = setImplied(I, delete) // Propagate access rights (MD).
                                                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                                                }
                                                                else
                                                                {
                                                                        errorBox(DBuser " is either not a part of {Engineering} or is a part of both user Groups\n\nPlease see the Administrator!")
                                                                }
                                                        }
                                                        else if(userGroup == "IV&V Lead")
                                                        {
                                                                u = find(DBuser)
                                                                if ((!member(EG, u) && !member(AE, u) && !member(EE, u) && !member(CE, u)) && (member(IL, u) ||  member(IE, u)))
                                                                {
                                                                        SetModAccess(I, read|modify, DBuser) // (RM).
                                                                        err = setImplied(I, null) // Turn off Propagate access rights.
                                                                                if (!null err){errorBox(fullName(I) "\n" err)}
                                                                }
                                                                else
                                                                {
                                                                        errorBox(DBuser " is either not a part of {IV&V} or is a part of both user Groups\n\nPlease see the Administrator!")
                                                                }
                                                        }
                                                        else if(userGroup != "IV&V Lead" && userGroup != "Engineering Lead")
                                                        {
                                                                // Set UserGroup/User
                                                                SetModAccess(I, read|create|modify, DBuser) // (RC).
                                                                err = setImplied(I, delete) // Propagate access rights (MD).
                                                                        if (!null err){errorBox(fullName(I) "\n" err)}
                                                        }
                                                }
                                        }
                                }
                                        
                                Module m = edit(fullName(I), false, true)
                                                
                                if(!null m)
                                {
                                        Reset(m)        
                                                
                                        save(m)
                                        close(m)
                                }else{errorBox("{Null} "fullName(I)"!")}
                        }
                        infoBox ("Done!")
                        
                        freeResources()
                        destroy(db)
                }else {warningBox("No User(s) selected!")}
        }else {warningBox "No item(s) selected!"}
 
}//End applyAccess
 
/**********************************
        applyAccess
***********************************/
void applyAccess (DB win)
{
        if(get(optionIndividualUser))
        {applyUser(win)}
        else
        {applyUserGroup(win)}
 
}//End applyAccess
 
/**********************************
        closedb
***********************************/
void closedb (DB win)
{
        freeResources()
        destroy(db)
}//End closedb
 
/**********************************
        resetshareable
***********************************/
void resetshareable (DB win)
{
        if (itemsSelected())
        {
                Item I
                
                //Set the reset shareable-edit on the selected items.
                for I in items do
                {
                        Module m = edit(fullName(I), false, true)
                        if(!null m)
                        {
                                Reset(m)
                                save(m)
                                close(m)
                        }else{errorBox("{Null} Module Parameter!")}
                }
                infoBox("Done!")
 
                destroy(db)
                freeResources()
        }
        //Warning user that no items are selected!
        else {warningBox "No item(s) selected!"}
}//End resetshareable.
 
/**********************************
        accessCallback
***********************************/
void accessCallback (DBE win, int check)
{
        // None [0]
        // Engineering Lead [1]
        // IV&V Lead [2]
        // Application Engineer [3]
        // 1E Engineer [4]
        // Hardware Engineer [5]
        // IV&V Engineer [6]
        // CNCS Engineer [7]
        // CNCS IV&V Engineer [8]
        //None is selected.
        if (check == 0 && getCheck (win, check))
        {
                //Future Code...
        }
        else if (check == 0 && !getCheck (win, check))
        {
                setCheck (win, 1, false)
                setCheck (win, 2, false)
                setCheck (win, 3, false)
                setCheck (win, 4, false)
                setCheck (win, 5, false)
                setCheck (win, 6, false)
                setCheck (win, 7, false)
                setCheck (win, 8, false)
        }
        //Engineering Lead is selected.
        else if (check == 1 && getCheck (win, check))
        {
                setCheck (win, 0, true)
                setCheck (win, 2, false)
                setCheck (win, 6, false)
                setCheck (win, 8, false)
        }
        else if (check == 1 && !getCheck (win, check))
        {
                setCheck (win, 3, false)
                setCheck (win, 4, false)
                setCheck (win, 5, false)
                setCheck (win, 7, false)
        }
        //IV&V Lead is selected.
        else if (check == 2 && getCheck (win, check))
        {
                setCheck (win, 0, true)
                setCheck (win, 1, false)
                setCheck (win, 3, false)        
                setCheck (win, 4, false)
                setCheck (win, 5, false)
                setCheck (win, 7, false)
        }
        else if (check == 2 && !getCheck (win, check))
        {
                setCheck (win, 6, false)
                setCheck (win, 8, false)
        }
        //Applicantion Engineer is selected.
        else if (check == 3 && getCheck (win, check))
        {
                setCheck (win, 0, true)
                setCheck (win, 1, true) 
                setCheck (win, 2, false)        
                setCheck (win, 6, false)        
                setCheck (win, 8, false)
        }
        //1E Engineer is selected.
        else if (check == 4 && getCheck (win, check))
        {
                setCheck (win, 0, true)
                setCheck (win, 1, true) 
                setCheck (win, 2, false)        
                setCheck (win, 6, false)
                setCheck (win, 8, false)                
        }
        //Hardware Engineer is selected.
        else if (check == 5 && getCheck (win, check))
        { 
                setCheck (win, 0, true)
                setCheck (win, 1, true) 
                setCheck (win, 2, false)        
                setCheck (win, 6, false)        
                setCheck (win, 8, false)
        }
        //IV&V Engineer is selected.
        else if (check == 6 && getCheck (win, check))
        {
                setCheck (win, 0, true)
                setCheck (win, 2, true) 
                setCheck (win, 1, false)        
                setCheck (win, 3, false)
                setCheck (win, 4, false)
                setCheck (win, 5, false)
                setCheck (win, 7, false)
        }
        //CNCS Engineer is selected.
        else if (check == 7 && getCheck (win, check))
        {
                setCheck (win, 0, true)
                setCheck (win, 1, true) 
                setCheck (win, 2, false)        
                setCheck (win, 6, false)
                setCheck (win, 8, false)
        }
        //CNCS Engineer is selected.
        else if (check == 8 && getCheck (win, check))
        {
                setCheck (win, 0, true)
                setCheck (win, 2, true) 
                setCheck (win, 1, false)        
                setCheck (win, 3, false)
                setCheck (win, 4, false)
                setCheck (win, 5, false)
                setCheck (win, 7, false)
        }
}//End accessCallback.
 
/**********************************
        addItemToList
***********************************/
void addItemToList (Item I)
{
        int count = 0
        int i = 0
        int rowNum = 0
        bool itemExists = false
        int listnum = noElems (moduleList)
        
        if (type (I) == "Formal")
        {
                //Check the item isn't all ready in the list.
                for (i = 0; i < listnum && !itemExists; i++)
                {
                        if (fullName(I) == (get (moduleList, i)))
                        {
                                itemExists = true       
                        }
                }
        
                //If not in the list all ready.
                if (!itemExists)
                {
                        //Add the formal module.
                        string ugName = null
                        LockList lList
                        Lock lck
                        ModName_ modRef = module (fullName (I))
                                
                        //Get the locks on the module if any.
                        lList = getLocksInModule (modRef, true)
                                
                        for lck in lList do
                        {
                                count++
                                ugName = lck.user
                        }           
                        if(count>1){ugName = ugName "{+}"}
                        
                        //Insert the module in the list with with normal icon if not locked.
                        if (!isLocked (modRef) || (isLocked (modRef) && ugName == null))
                        {
                                insert (moduleList, rowNum, fullName (I), iconFormal)
                                set (moduleList, rowNum, 1, ugName)
                                put (items, I, I)                       
                        }
                        //Insert the item in the list with the deleted icon indicating it is locked
                        //and will not be processed.
                        else
                        {
                                Icon ic = addr_ 174
                                insert (moduleList, rowNum, fullName (I), ic)
                                set (moduleList, rowNum, 1, ugName)
                        }
                                
                        rowNum++
                        delete(lList)   
                }
        }
}//End addItemToList.
 
/**********************************
        listViewSelect
***********************************/
void listViewSelect (DBE win, int i)
{
        //Do nothing.   
}//End listViewSelect.
 
/**********************************
        listViewDeselect
***********************************/
void listViewDeselect (DBE win, int i)
{
        //Do nothing.
}//End listViewDeselect.
 
/**********************************
        treeSelect
***********************************/
void treeSelect (DBE win)
{
        //Do nothing.
}//End treeSelect
 
/**********************************
        listActivate
***********************************/
void listActivate (DBE win, int i)
{
        //Delete the item from the list.
        delete (itemList, i)
        numItems--
}//End listActivate.
 
/**********************************
        treeActivate
***********************************/
void treeActivate (DBE win)
{
        Buffer temp = create (1)
        
        bool itemSelected = false
        int listnum = noElems (moduleList)
        int i = 0
        
        Item I
        
        temp += "/" get (win)
        
        I  = item (tempStringOf (temp))
        
 
        //Make sure the item hasn't been selected all ready.
        for (i = 0; i < numItems && !itemSelected; i++)
        {
                if (tempStringOf (temp) == (get (itemList, i)))
                {
                        itemSelected = true     
                }
        }
        
        if(!itemSelected)
        {
                for (i = 0; i < listnum && !itemSelected; i++)
                {
                        if (tempStringOf (temp) == (get (moduleList, i)))
                        {
                                itemSelected = true     
                        }
                }
        }
        
        if (!itemSelected)
        {
                if (type (I) == "Formal")
                {
                        if(canControl(I))
                        {
                                //Enter the module in the items list.
                                insert (itemList, numItems, tempStringOf (temp), iconFormal)
                                numItems ++
                        }
                        else
                        {
                                errorBox("Cannot switch access {" name(I) "}")
                        }
                }
        }
        else
        {
                //Let the user know the module was all ready selected.
                warningBox("Item has all ready been selected.")
        }
 
        delete (temp)
}//End treeActivate.
 
/**********************************
        addItemsCallback
***********************************/
void addItemsCallback (DB win)
{
        Item I
        
        //Loop through the items in the list and add them to the selected items on the main DB.
        for (i = 0; i < numItems; i++)
        {
                I = item (get (itemList, i))
                
                addItemToList (I)
        }
}//End addItemsCallback.
 
/**********************************
        addItemToList
***********************************/
void addItemToList (DB win)
{
        string listViewItems []
        
        //Create the Add Items dialog box.
        DB addItems = create ("Add Items", styleCentered|styleStandard|styleFloating)
        
        Project p
        
        Item I
        
        //Set the number of items to 0.
        numItems = 0
        
        //Create the dialog box elements.
        treeFrame = frame (addItems, "Select Items:", 350, 250)
        listFrame = frame (addItems, "Selected Items:", 500, 250)
        itemTree = treeView (addItems, treeViewOptionSorted, 250, 10)
        itemList = listView (addItems, 0, 35, 15, listViewItems)
        
        set (itemTree, treeSelect, treeActivate)
        set (itemList, listViewSelect, listViewDeselect, listActivate)
        
        //Position the dialog box elements.
        treeFrame->"right"->"unattached"
        treeFrame->"bottom"->"form"
        listFrame->"top"->"aligned"->treeFrame
        listFrame->"right"->"form"
        listFrame->"left"->"spaced"->treeFrame
        listFrame->"bottom"->"form"
        itemTree->"top"->"inside"->treeFrame
        itemTree->"left"->"inside"->treeFrame
        itemTree->"right"->"inside"->treeFrame
        itemTree->"bottom"->"inside"->treeFrame
        itemList->"top"->"inside"->listFrame
        itemList->"left"->"inside"->listFrame
        itemList->"right"->"inside"->listFrame
        itemList->"bottom"->"inside"->listFrame
 
        //Add the OK Button.
        ok (addItems, "Add Items", addItemsCallback)
        
        //Show the DB.
        realize (addItems)
 
        //Insert a column in the itemList listView.
        insertColumn (itemList, 0, "Items", 480, iconNone)    
                
        //Loop through all the items in the database by project and 
        //insert them into the treeView.
        for p in database do
        {
                insert (itemTree, fullName (p), iconProject, iconProjectOpen)
                
                for I in p do
                {
                        if(isDeleted(I) || null I) {continue}
                        
                        if (type (I) == "Folder")
                        {
                                insert (itemTree, fullName (I), iconFolder, iconFolderOpen)
                        }
                        else if (type (I) == "Formal")
                        {
                                if(canControl(I))
                                {
                                        if(Uname == "Administrator" && ReadOnly(I))
                                        {
                                                Icon ic = addr_ 33
                                                insert (itemTree, fullName (I), ic, ic)
                                        }
                                        else
                                        {
                                                Icon ic = addr_ 52
                                                insert (itemTree, fullName (I), ic, ic)
                                        }
                                }
                                else
                                {
                                        if(ReadOnly(I))
                                        {
                                                Icon ic = addr_ 33
                                                insert (itemTree, fullName (I), ic, ic)
                                        }
                                        else
                                        {
                                                Icon ic = addr_ 35
                                                insert (itemTree, fullName (I), ic, ic)
                                        }
                                }
                        }
                }   
        }
}//End addItemToList.
 
/**********************************
        removeItemFromList
***********************************/
void removeItemFromList (DB win)
{
        int i = 0
        bool msg = true
        
        //Loop through the module list.
        for (i = noElems (moduleList); i >= 0; i--)
        {   
                //If the item is selected then remove it from list to process.
                if (selected (moduleList, i))
                {   
                        delete (items, get (moduleList, i))
                        delete (moduleList, i)
                        msg = false
                }   
        }
        
        if(msg){warningBox "No item(s) selected!"}
}//End removeItemFromList.
 
/**********************************
        createDB
***********************************/
void createDB ()
{
        User uX
        bool ugDisabled 
        
        string temp []
        string access [9] = {"None", "Engineering Lead", "IV&V Lead", "Application Engineer", "1E Engineer", "Hardware Engineer", "IV&V Engineer", "CNCS Engineer","CNCS IV&V Engineer"}
        string ugName
        
        int userNum = 0
        
        Item I
        
        if(!validation()){freeResources();halt;}
        
        //Start building the dialog box.
        db = create ("Grant/Remove Access", styleStandard|styleCentered)
        moduleList = listView (db, listViewOptionMultiselect, 495, 15, temp)
        optionIndividualUser = toggle(db,"Indvidual User(s)",false)
        beside(db)
        optionAppendUsers = toggle(db,"Append User(s)",false)
        accessListView = listView (db, listViewOptionCheckboxes, 155, 9, access)
        userListView = listView (db, listViewOptionMultiselect, 225, 8, temp)
        apply (db, "Add Item(s)", addItemToList)
        apply (db, "Remove Item(s)", removeItemFromList)
        apply (db, "Reset Shareable", resetshareable)
        apply (db, "Apply", applyAccess)
        close (db, true, closedb) 
 
        //Placement of the DBE's on the dialog box.
        accessListView->"right"->"unattached"
        accessListView->"bottom"->"form"
        userListView->"top"->"aligned"->accessListView
        userListView->"left"->"spaced"->accessListView
        
        realize (db)
 
        //Put the appropriate columns in the list views.
        insertColumn (userListView, 0, "Username", 200, iconNone)
        insertColumn (userListView, 1, "User", 100, iconNone)
        insertColumn (accessListView, 0, "Access", 150, iconNone)
        insertColumn (moduleList, 0, "Selected Items", 400, iconNone)
        insertColumn (moduleList, 1, "Locked By", 90, iconNone)
        
        bool trig = false
        Group ILG = find("IV&V Lead")
        Group IEG = find("IV&V Engineer") 
        
        if(member(IEG, u)){trig = true}
        
        //Add the users to the user list view.
        for uX in userList do
        {
                ugDisabled = uX.disabled
                if(ugDisabled) {continue}
                
                if(trig)
                {
                        if((member(ILG, uX) || member(IEG, uX)) && !ugDisabled)
                        {
                                ugName = uX.name
                                insert (userListView, userNum, ugName, iconUser)
                                ugName = uX.fullName
                                set (userListView, userNum, 1, ugName)
                                userNum++
                        }
                }
                else
                {
                        if((!member(ILG, uX) && !member(IEG, uX)) && !ugDisabled)
                        {
                                ugName = uX.name
                                insert (userListView, userNum, ugName, iconUser)
                                ugName = uX.fullName
                                set (userListView, userNum, 1, ugName)
                                userNum++
                        }
                }
        }
        
        //Get the selected items and add them to the module list view.
        for I in selectedItems do
        {
                if (!isDeleted (I) || null I)
                {
                        if(canControl(I))
                        {
                                addItemToList (I)
                        }
                        else
                        {
                                errorBox("Cannot switch access {" name(I) "}")
                        }
                }
        }
        
        Group CTF = find("CTF")
        if(member(CTF, u) && Uname != "Administrator") 
        {
                inactive(accessListView)
                inactive(optionAppendUsers)
                inactive(userListView)
                inactive(optionIndividualUser)
                
                setCheck (accessListView, 0, true)
                setCheck (accessListView, 1, true)
        }
        else
        {
                inactive(userListView)
                inactive(optionAppendUsers)
        }
        
        //Set the sort on the list views.
        set (userListView, 0, sortListView)
        set (userListView, 1, sortListView)
        
        //Set the callback for the access list view.
        set (accessListView, accessCallback)
        set (optionIndividualUser, optionCallback)
        
        //Warning user that no items are selected!
        if(!itemsSelected()){warningBox("No module(s) selected to process!")}
                
        //Show the dialog box.
        show (db)
}//End createDB.
 
//Call function.
createDB ()

SystemAdmin - Tue Jun 26 10:32:47 EDT 2012

Re: logic help needed. Thank you
llandale - Tue Jun 26 16:37:12 EDT 2012

My user scripts take a long time as well and frankly I don't know what to do about it.

Re: logic help needed. Thank you
Mathias Mamsch - Wed Jun 27 06:20:36 EDT 2012

I remember we had some threads about that, and I think someone found a solution:

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14327061&#14327061

That is the one thread, that I found, but maybe a more intensive search will bring you more insight. Maybe that helps, regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: logic help needed. Thank you
SystemAdmin - Wed Jun 27 10:42:41 EDT 2012

Mathias Mamsch - Wed Jun 27 06:20:36 EDT 2012
I remember we had some threads about that, and I think someone found a solution:

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14327061&#14327061

That is the one thread, that I found, but maybe a more intensive search will bring you more insight. Maybe that helps, regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Hello,

I really did find a solution for the userList performance issue. I was thinking of calling the grantaccess.dxl within the startup.dxl. What is the trick for overriding the GUI I would like to run the grantaccess script on startup so that the user wouldn't even realize it running how would you execute this? By runing the script it would populate the userList then I would like it to end the script while making sure are resouces are freed. Thank you.

-Jim

// override some default message box functions, so they will only print the data but 
// not pause execution. Write to a log file here! 
 
bool confirm (string s) {return true }
void ack (string s) {}
void acknowledge (string s) {}
void infoBox (string s) {}
void errorBox (string s) {}
void warningBox (string s) {}
void info (string s) {}
 
DB tmpDB = null
 
// Now override block and show, to only do realize
void show  (DB x) { realize x; tmpDB = x }
void block (DB x) { realize x; tmpDB = x }
 
{
    #include <c:/grantaccess.dxl>
}
 
destroy tmpDB

Re: logic help needed. Thank you
Mathias Mamsch - Thu Jun 28 08:09:44 EDT 2012

SystemAdmin - Wed Jun 27 10:42:41 EDT 2012

Hello,

I really did find a solution for the userList performance issue. I was thinking of calling the grantaccess.dxl within the startup.dxl. What is the trick for overriding the GUI I would like to run the grantaccess script on startup so that the user wouldn't even realize it running how would you execute this? By runing the script it would populate the userList then I would like it to end the script while making sure are resouces are freed. Thank you.

-Jim

// override some default message box functions, so they will only print the data but 
// not pause execution. Write to a log file here! 
 
bool confirm (string s) {return true }
void ack (string s) {}
void acknowledge (string s) {}
void infoBox (string s) {}
void errorBox (string s) {}
void warningBox (string s) {}
void info (string s) {}
 
DB tmpDB = null
 
// Now override block and show, to only do realize
void show  (DB x) { realize x; tmpDB = x }
void block (DB x) { realize x; tmpDB = x }
 
{
    #include <c:/grantaccess.dxl>
}
 
destroy tmpDB

I am not sure I understand why you would want the grantAccessScript to be run on every startup, but you if so, you should remove the GUI part from the script, which should take you like 30 minutes or so. If you want to keep GUI functionality, separate GUI from functionality and launch without GUI on startup.

If you decide you want to keep "Automatizing the GUI", then you would need to invoke some callback after the include, e.g. resetshareable or applyAccess. Maybe that help, regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS